package com.fcbox.bypass.mapper;

import com.fcbox.bypass.domain.UicUser;
import lombok.Setter;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * UicMapper
 * Created by 000498 on 2017/5/12.
 */
@Mapper
@Repository
public interface UicMapper {
	@Select("select id from uic_user where mobile_phone=#{mobile} and is_del = 0 limit 0,1")
	Long getUserIdByMobile(@Param("mobile") String mobile);

	/**
	 * 使用ResultMap注解，可以将结果集影射到xml中配置的resultMap
	 * @param mobile
	 * @return
	 */
	@Select("select id, uuid, mobile_phone from uic_user where mobile_phone=#{mobile} and is_del = 0 limit 0,1")
	@ResultMap("com.fcbox.bypass.mapper.domain.UicUser.UicUserMapper")
	UicUser getUserByMobile(@Param("mobile") String mobile);

	@Select("select province from uic_user where mobile_phone = #{mobile}")
	List<String> getProvinceListByMobile(String mobile);

	@Update("update uic_user set province = '广东' where id = #{userId}")
	int updateProvence(Long userId);
}
